/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __418D074F_424B_443d_9A20_9A2AF787140E__
#define __418D074F_424B_443d_9A20_9A2AF787140E__

#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos
{
    // 
    // spin_impl
    // 
    class spin_impl : public xos_stl::mem_item< release_impl< spin_impl >, thread_lock >,
        public i_lock
    {
    public:
        typedef release_impl< spin_impl > T;

    public:
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //
        static int get_xos_item_data( ITEM_DATA*& item_ptr );

    public:
        spin_impl();
        ~spin_impl();

    protected:
        spin m_lock;

    public:
        int init();
        int term();

    public:
        // 
        // un lock
        // 
        int un_lock();

        // 
        // lock
        // 
        int lock();
    };
} // xos

#endif // __418D074F_424B_443d_9A20_9A2AF787140E__
